package cn.crdeng.controller;

import cn.crdeng.Service.BlogService;
import cn.crdeng.exception.NotFoundException;
import cn.crdeng.po.Blog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


@Controller("blogController1")
public class BlogController {
    @Autowired
    private BlogService blogService;
    @GetMapping("/blog/{id}")
    public String getBlog(@PathVariable Long id, Model model){
        Blog blogByID = blogService.getAndConvert(id);
        blogService.addViews(id);
        model.addAttribute("blog",blogByID);
        return "blog";
    }
}
